<?php
define("_needlogin", "0");
define("_access", "1");
include_once("include/db.config.php"); 

$sql = "SELECT C.name as chalName, T.name as TeamName, M.name as MemberName, S.time, S.plus, S.rank
        FROM challenge as C, team as T, submitLog as S, member as M
        WHERE S.teamId=T.id and S.challengeId=C.id and T.captainID = M.student_id
        order by S.time desc
        limit 0,50";
//echo $sql;
$result = getAll($sql);

//var_dump($result);

?>
<!DOCTYPE html>
<html>
<?php include("include/head.php"); ?>
<body>
<?php include("include/nav.php"); ?>

<link rel="stylesheet" type="text/css" href="/static/css/c3.min.css">
<style type="text/css">
    .no-return{
        white-space:nowrap;
    }
</style>

<div class="row">
    <br>
    <?php 
        if(!$result){
            echo "<center>暂无战况</center>";
            die();
        }else{
            echo "<h1>实时战况 (最多当前最新的50条记录)</h1>";
        }
    ?>
    <table id="teamsboard">
        <thead>
            <tr>
                <td><b class="no-return">提交时间</b></td>
                <td><b class="no-return">提交人</b></td>
                <td><b class="no-return">提交题目</b></td>
                <td><b class="no-return">此题名次</b></td>
                <td><b class="no-return">额外加分</b></td>
            </tr>
        </thead>
        <tbody>
            <?php 
            foreach ($result as $key => $value) {  ?>
            <tr>
                <td><span class="no-return"><?php echo $value['time'];?></span></td>
                <td><span class="no-return"><?php echo $value['TeamName'];?></span></td>
                <td><span class="no-return"><?php echo $value['chalName'];?></span></td>
                <td><span class="no-return"><?php echo $value['rank']==1?'First Blood !':$value['rank'];?></span></td>
                <td><span class="no-return"><?php echo $value['plus'];?></span></td>
            </tr>
            <?php } ?>
        </tbody>
    </table>
</div>
        
<?php include("include/script.php"); ?>
</body>
</html>